<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="main">

    </div>
    <script>
        const data=Array(1000).fill(undefined).map((item,index)=>`第${index}个元素`);
        const length=data.length;
        var oMain=document.getElementById('main');
        let oFragment=document.createDocumentFragment();
        let str='';
        // 1. data.length 交给变量
        // 2. 文档碎片 减少重排
        for(var i=0;i<data.length;i++){
            // var li=document.createElement('li');
            // li.innerText=data[i];
            // oFragment.appendChild(li);
            str+=`<li>${data[i]}</li>`
        }
        // oMain.appendChild(oFragment);
        oMain.innerHTML=str;
    </script>
</body>
</html>